package com.sxapp.util;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.sxapp.entity.User;

public class GetSession {
	public static User getUser(HttpServletRequest request) {
		 HttpSession session = request.getSession();
 		 User User = (User) session.getAttribute("User"); 
   	     return User;
	}
	public static boolean JudgeUser(HttpServletRequest request,HttpServletResponse response) {
		 HttpSession session = request.getSession();
		 User User = (User) session.getAttribute("User"); 
		 if(User==null) {
			 try {
				response.sendRedirect("/user/login");
				return true;
			} catch (IOException e) {
			}
		 }
		 return false;
	}
}
